﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._06_策略模式
{
    /// <summary>
    /// 具体策略：百分比折扣
    /// </summary>
    public class PercentageDiscount: IDiscountStrategy
    {
        /// <summary>
        /// 折扣金额
        /// </summary>
        private readonly decimal _percentage;

        public PercentageDiscount(decimal percentage)
        {
            _percentage = percentage;
        }

        /// <summary>
        /// 使用折扣
        /// </summary>
        /// <param name="originalPrice"></param>
        /// <returns></returns>
        public decimal ApplyDiscount(decimal originalPrice) => originalPrice * (1 - _percentage / 100);

    }
}
